package iscte.iul.dcti.pa.a2013_14.filter;

import java.util.ArrayList;
import java.util.List;

public class StringFilter  {
	
	public void addWord(String myString) {
		this.palavras.add(myString);		
	}	
	
	public void addFilter(Filter myFilter) {
		filters.add(myFilter);
	}
	
	public void addString(String myString) {
		this.palavras.add(myString);
	}
	
	public void addStrings(ArrayList<String> myStrings) {
		for (String myString : myStrings) {
			this.palavras.add(myString);
		}
	}
		
	
	public String getFilteredStrings()
	{	
		StringBuilder builder = new StringBuilder();
		
		for (String minhaString : palavras) {
			for (Filter filtro : filters) {
				if (filtro.accept(minhaString)) {
					builder.append(minhaString + ";");
				}
			}
		}
		return builder.toString();
	}
	
	//construtores
	public StringFilter() {
		palavras = new ArrayList<>();
		filters = new ArrayList<Filter>();
	}
	
	//atributos
	private ArrayList<String> palavras;
	private List<Filter> filters;
}
